import type { RouteRecordRaw } from 'vue-router';

import { traverseTreeValues } from '@core/shared/utils';

import {
  defaultRoutes,
  whiteListRoutes,
  fallbackNotFoundRoute,
} from './default';

/**
 * 路由列表，由基本路由、外部路由和404兜底路由组成
 * 无需走权限验证（会一直显示在菜单中）
 */
const routes: RouteRecordRaw[] = [
  ...whiteListRoutes,
  ...defaultRoutes,
  fallbackNotFoundRoute,
];

/** 基本路由列表，这些路由不需要进入权限拦截 */
const whiteListRoutesNames = traverseTreeValues(
  whiteListRoutes,
  (route) => route.name,
);

export { whiteListRoutesNames, routes };
